﻿namespace Leetcode.N0001;

public class Solution
{
    public int[] TwoSum(int[] nums, int target)
    {
        var dic = new System.Collections.Generic.Dictionary<int, int>();
        for (var i = 0; i < nums.Length; i++)
        {
            var d = target - nums[i];
            if (dic.ContainsKey(d))
            {
                return new int[] { dic[d], i };
            }
            else
            {
                if (dic.ContainsKey(nums[i]))
                {
                    continue;
                }
                dic.Add(nums[i], i);
            }
        }

        return new int[0];
    }
}
